package com.haoyeteng.sxbd.modular.business.controller;

import com.haoyeteng.sxbd.core.base.controller.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
import com.haoyeteng.sxbd.core.base.model.ResponseResult;
import com.haoyeteng.sxbd.core.common.annotion.Permission;
import java.util.List;
import java.util.Map;
import com.haoyeteng.sxbd.core.log.LogObjectHolder;
import org.springframework.web.bind.annotation.RequestParam;
import com.haoyeteng.sxbd.modular.business.model.Coordinate;
import com.haoyeteng.sxbd.modular.business.service.ICoordinateService;

/**
 * 坐标点控制器
 *
 * @author haoyeteng
 * @Date 2019-07-17 23:16:14
 */
@Controller
@RequestMapping("/coordinate")
public class CoordinateController extends BaseController {

    private String PREFIX = "/business/coordinate/";

    @Autowired
    private ICoordinateService coordinateService;

    /**
     * 跳转到坐标点首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "coordinate.html";
    }

    /**
     * 跳转到添加坐标点
     */
    @RequestMapping("/coordinate_add")
    public String coordinateAdd() {
        return PREFIX + "coordinate_add.html";
    }

    /**
     * 跳转到修改坐标点
     */
    @RequestMapping("/coordinate_update/{coordinateId}")
    public String coordinateUpdate(@PathVariable Integer coordinateId, Model model) {
        Coordinate coordinate = coordinateService.selectById(coordinateId);
        model.addAttribute("item",coordinate);
        LogObjectHolder.me().set(coordinate);
        return PREFIX + "coordinate_edit.html";
    }

    /**
     * 获取坐标点列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    @Permission
    public ResponseResult<Object> list(String condition) {
    	ResponseResult<Object> result = new ResponseResult<Object>();
        result.setData(0);
 		result.setCount(0);
     	result.setCode(SUCCESS_TIP.getCode());
     	result.setMsg(SUCCESS_TIP.getMessage());
 		return result;
    }

    /**
     * 新增坐标点
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    @Permission
    public Object add(Coordinate coordinate) {
        coordinateService.insert(coordinate);
        return SUCCESS_TIP;
    }

    /**
     * 删除坐标点
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    @Permission
    public Object delete(@RequestParam Integer coordinateId) {
        coordinateService.deleteById(coordinateId);
        return SUCCESS_TIP;
    }

    /**
     * 修改坐标点
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    @Permission
    public Object update(Coordinate coordinate) {
        coordinateService.updateById(coordinate);
        return SUCCESS_TIP;
    }

    /**
     * 坐标点详情
     */
    @RequestMapping(value = "/detail/{coordinateId}")
    @ResponseBody
    public Object detail(@PathVariable("coordinateId") Integer coordinateId) {
        return coordinateService.selectById(coordinateId);
    }
}
